﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AutoFrom.aspx.cs" ResponseEncoding="gb2312" Inherits="ZX.WebApp.Mobi.AutoFrom" %>
<!DOCTYPE html>
<%--<html manifest="autofrom.manifest">--%>
<html>
<head>
    <title>移动审批</title>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta http-equiv="Pragma" content="no-cache" />
    <link rel="stylesheet" href="../Scripts/Jquery/formValidator.2.5.4.1/css/template.css"
        type="text/css" />
    <link rel="stylesheet" href="../Scripts/Jquery/formValidator.2.5.4.1/css/validationEngine.jquery.css"
        type="text/css" />
    <link href="../Styles/fbmodal.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="css/icons1.2.css" title="default" />
    <link rel="stylesheet" type="text/css" href="css/jq.ui.less1.2.css" title="default" />
    <script src="../Scripts/Jquery/formValidator.2.5.4.1/js/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
    <script src="../Scripts/Jquery.form.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.upload.js" type="text/javascript"></script>
    <script src="../Scripts/CombinButton.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script src="../Scripts/Guid.js" type="text/javascript"></script>
    <script src="../Scripts/formReForm.js" type="text/javascript"></script>
    <script src="../Scripts/Appjs/CheckModel.js" type="text/javascript"></script>
    <script src="../Scripts/Jquery/ComBox/babu.common.js" type="text/javascript"></script>
    <script src="../Scripts/Jquery/ComBox/babu.combobox.js" type="text/javascript"></script>
    <script src="../Scripts/Jquery/formValidator.2.5.4.1/js/jquery.validationEngine.js"
        type="text/javascript"></script>
    <script src="../Scripts/Jquery/formValidator.2.5.4.1/js/languages/jquery.validationEngine-zh_CN.js"
        type="text/javascript"></script>
    <script src="../Scripts/jquery.fbmodel.js" type="text/javascript"></script>
    <script src="../Scripts/Bpmjs/BpmForm.js" type="text/javascript"></script>
    <script src="../Scripts/Jquery/DesignForm/DesignForm.Common.js" type="text/javascript"></script>
    <script src="../Crm/BasePages/Workflow.js" type="text/javascript"></script>
    <script src="../Scripts/Jquery/uni-form/uni-form-validation.jquery.js" type="text/javascript"></script>
    <script src="Approval.js" type="text/javascript"></script>
    <script src="WorkflowManager.js" type="text/javascript"></script>
    <script type="text/javascript" charset="utf-8" src="./js/jq.mobi.min1.2.js"></script>
    <link href="css/mobiscroll-2.2.custom.min.css" rel="stylesheet" type="text/css" />
	<script src="plugins/mobiscroll-2.2.custom.min.js" type="text/javascript"></script>
    <script type="text/javascript" charset="utf-8" src="./ui/jqui12.js"></script>
    <script type="text/javascript" charset="utf-8" src="./plugins/jq.popup.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/public.js"></script>
    
    
    <script type="text/javascript">
        function loadedPanel(what)
        {
            jq.ui.hideMask();
            jq.ui.clearHistory();
            if (what.id == "firstpage")
            {
            }
        }
        function unloadedPanel(what)
        {
            console.log("unloaded " + what.id);
        }
        if (!((window.DocumentTouch && document instanceof DocumentTouch) || 'ontouchstart' in window))
        {
            var script = document.createElement("script");
            script.src = "js/touch.js";
            var tag = jq("head").append(script);
            jq.os.android = true;
            jq.os.desktop = true;
        }
        var oldElem = "default";
        function setActiveStyleSheet(title)
        {
            var a = document.getElementsByTagName("link");
            var currElem;

            if (title == oldElem.getAttribute("title") || oldElem == "default")
                return;
            for (i = 0; i < a.length; i++)
            {

                if (a[i].getAttribute("title") == title)
                {
                    currElem = a[i];
                }
                else if (!a[i].getAttribute("disabled") && a[i].getAttribute("title"))
                    oldElem = a[i];
            }

            currElem.removeAttribute("disabled");
            jq.ui.showMask();
            window.setTimeout(function ()
            {
                jq.ui.hideMask();
                oldElem.setAttribute("disabled", "true");
            }, 500);
        }
        jq(document).ready(function ()
        {
            oldElem = document.getElementsByTagName("link")[0];
        });
    </script>
    <style type="text/css">
    #testform 
    {
        float:left;
        width:100%; height:auto;
    }
     ul 
    {
        width:100%;
        float:left;
    }
 
    ul > li 
    {
        width:80px;
        float:left;
    } 
    .jquiinput { 
	display:inline-block;
	width:100%;
	min-width:150px;
	margin-top:4px; margin-bottom:12px;
	padding:8px;
	border:solid 1px #493325;
	outline:0;
	font:normal 1em/1.5em Helvetica, Arial, sans-serif;
	color:#36251B;
	background:#E6E2B5;
	-webkit-border-radius:6px; border-radius:6px;
	-webkit-box-shadow:inset 1px 1px 4px rgba(54,37,27,0.3); box-shadow:inset 1px 1px 4px rgba(54,37,27,0.3);
}
    </style>
    <script type="text/javascript">
        /* This function runs once the page is loaded, but appMobi is not yet active */
        var webRoot = "./css/";
        jq.ui.autoLaunch = false;
        jq.ui.openLinksNewTab = false;
        jq.ui.resetScrollers = false;
        var init = function ()
        {
            jq.ui.backButtonText = "后退";
            window.setTimeout(function () { jq.ui.launch(); }, 400);
            //$.ui.removeFooterMenu(); This would remove the bottom nav menu
        };
        document.addEventListener("DOMContentLoaded", init, false);
        jq.ui.ready(function () { });

        /* This code is used to run as soon as appMobi activates */
        var onDeviceReady = function ()
        {
            AppMobi.device.setRotateOrientation("portrait");
            AppMobi.device.setAutoRotate(false);
            webRoot = AppMobi.webRoot + "css/";
            //hide splash screen
            AppMobi.device.hideSplashScreen();
            jq.ui.blockPageScroll(); //block the page from scrolling at the header/footer

        };
        document.addEventListener("appMobi.device.ready", onDeviceReady, false);
    
</script>
</head>
<body>
    <div id="jQUi">
        <div id="splashscreen" class='ui-loader'>
        <br><br>
        <span class='ui-icon ui-icon-loading spin'></span><h1 >正在为你努力加载表单信息<br />请稍候...</h1>
    </div>
        <div id="header">
            <a href="javascript:closewindows();" id="abacklist" class="button" style="float: left;
                display: inline-block;">返回</a>
            <a href="javascript:audaction();" id="btnopperate" class="button" style="float: right;
                display: inline-block;">操作</a>
        </div>
        <div id="content">
            <div title='表单信息' id="main"class="panel" selected="true" data-load="loadedPanel" data-unload="unloadedPanel" data-tab="navbar_home">
                <form id="form1" class="uniForm" runat="server">
                <fieldset>
                    <div class="fieldForm" id="fieldForm">
                        <asp:Literal ID="FormTemplate" runat="server"></asp:Literal>
                    </div>
                </fieldset>
                </form>
                <form id="form2" action="../Extend/AjaxData/DataSave.aspx">
                <textarea style="display: none" id="jsonDataContent" rows="2" cols="2" name="jsonDataContent"></textarea>
                <textarea style="display: none" id="jsonDetails" rows="2" cols="2" name="Details"></textarea>
                </form>
            </div>
            <div id="nowaud" title="当前审批信息" class="panel" data-load="loadedPanel" data-unload="unloadedPanel" data-tab="navbar_home">
                <fieldset>
                    <legend>审批人:<%= this.User.UName %></legend><legend>审批时间：<%= DateTime.Now %></legend>
                    <label for="name">
                        审批意见</label><br />
                    <textarea id="txtsubject" name="web" class='jq-ui-forms'></textarea>
                    <label id="zuserName" for="name">
                        转发处理者</label><br />
                    <input id="hdzuser" type="hidden" value="" />
                    <input id="txtzuser" type="text" value="" class='jq-ui-forms' /><br />
                </fieldset>
            </div>
            <div id="hisaud" title="历史审批信息" class="panel" data-load="loadedPanel" data-unload="unloadedPanel" data-tab="navbar_home">
              <asp:Repeater ID="rptCheckInfo" runat="server">
                        <ItemTemplate>
                            <fieldset>
                                <legend>审批人:<%#Eval("AuditUserName") %></legend>
                                <label for="name">
                                <%#Eval("AuditArch") %>、<%#Eval("AuditDuty") %>
                                </label><br /><br />
                                <label for="name">
                                    审批意见</label><br />
                                <textarea  readonly="readonly"  style=" min-height:80px;"   class='jq-ui-forms' ><%#Eval("Message") %></textarea>
                                <label for="name">
                                    审批时间</label>
                                <input type="text" readonly="readonly" value="<%#Eval("AuditTime") %>" class='jq-ui-forms' />
                                <label for="name">
                            </fieldset>
                        </ItemTemplate>
                    </asp:Repeater>
            </div>
            <div id="userselect" title="人员选择" class="panel" data-load="loadedPanel" data-unload="unloadedPanel" data-tab="navbar_home">
                <table cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                        <td>
                            <label for="name">
                                选择部门</label>
                        </td>
                        <td>
                           <span>
                           <select id="SelectForDept">
                           <option value=""> </option>
                           <%=DeptHtml%>
                           </select> </span>
                        </td>
                        <td>
                            <button id="btnQuery" type="button" onclick="SelectDetp();" class="button">
                                查询</button>
                        </td>
                         
                    </tr>
                    <tr>
                        <td>
                            <label for="name">
                                员工姓名</label>
                        </td>
                        <td>
                            <input id="selectname" type="text"  style="display:inline-block;width:65%;
	                            margin-top:4px; margin-bottom:12px;padding:8px;border:solid 1px #493325;
	                           outline:0;font:normal 1em/1.5em Helvetica, Arial, sans-serif;color:#36251B;
	                        background:#E6E2B5; -webkit-border-radius:6px; border-radius:6px;
	                        -webkit-box-shadow:inset 1px 1px 4px rgba(54,37,27,0.3); box-shadow:inset 1px 1px 4px rgba(54,37,27,0.3);" />
                        </td>
                        <td > <button id="btnConfirm" type="button" onclick="btnconfirm();" class="button">
                                选定</button>
                                </td>
                    </tr>
                </table>
                <table>
                <tr>
                <td>
                <fieldset style="width:1090px">
                    <legend>查询结果</legend>
                    <div id="testform"></div>

                </fieldset>
                </td>
                               
                 </tr>
                </table>
            </div>
        </div>
        <div id="navbar">
            <a href="#main" class='icon paper'>表单信息</a>
            <%=DetailsPage%>
            <a href="#hisaud" class="icon tag">审批记录</a>
            <a href="#nowaud" class="icon new">当前审批</a>
        </div>
    </div>
</body>
<script type="text/javascript">

        var _WorkflowId = '<%=WorkFlowId %>',
           _WorktaskId = '<%=WorkTaskId %>',
           _WorkFlowInsId = '<%=WorkFlowInsId %>',
           _WorkTaskInsId = '<%=WorkTaskInsId %>',
           _OperatorInsId = '<%=OperatorInsId %>',
           _TableName = '<%=TableName %>',
           _KeyValue = '<%=KeyValue %>',
        _FormType = '<%=FormType %>',
           _UserName = '<%=UserName %>',
           _LoginName='<%=LoginName %>'
        _CancelFlag = '';
      
        _IsPagereturn = '0';
        _IsAssgin = '0';
        _IsDraft = '<% =IsDraft %>';
        _IsIE = '0';//'<%=IsIE %>;'

        var items = '<%=Status %>'.toString();
        var _OperType='<%=OperType %>';
        var operstatus = '<%=OperTypeStatus %>'.toString();
        _CancelFlag = items;

        var url = "../Extend/AjaxData/DataSave.aspx",
        entity = "<% =EntityName %>";
        var const_KeyValue = "<% =KeyValue %>";
        var Parent = parent;
        <asp:Literal ID="EditTemplate" runat="server"></asp:Literal>
        <asp:Literal ID="MasterID" runat="server"></asp:Literal>
        //alert(instance[0].EntityName);

        if(items.toString() == "3")
        {
            var item  = $("#form1").SetControlReadOnly();
        }
        
        if (items == '4') { _IsPagereturn = '1'; }
        if (_IsDraft == '1') { _IsPagereturn = '1'; }

        var getentity="<% =EntityName %>";
        var getid="<%=GetID%>";

    var _CallBack;
    var _page;
    $(document).ready(function(){
        
        if(getentity.indexOf("bpm_",0)<0){
            if(typeof(parent.parent.NeedRefreshPage)!="undefined" )
            {
    
               _page = parent.parent.NeedRefreshPage;
               if(_page!=null){
                  _CallBack = _page.CallBack;
               }
            }
            else
            {
                if(typeof(parent.NeedRefreshPage)!="undefined")
                {
                    _page = parent.NeedRefreshPage;
                     if(_page!=null)
                     {
                         _CallBack = _page.CallBack;
                     }
               }
            }
        }
    });

   //输入字符限制
    function confine(msg, oMaxNum, maxNum) {
        var iLen = 0;
        for (i = 0; i < msg.val().length; i++)
            iLen += msg.val().charAt(i).charCodeAt() > 255 ? 1 : 0.5;
        maxNum - Math.floor(iLen) >= 0 ? sendFlag = 0 : sendFlag = 1;
        if (sendFlag == 0) {
            oMaxNum.html("还能输入<em>" + Math.abs(maxNum - Math.floor(iLen)) + "</em>字");
            oMaxNum.css("color", "");
        }
        else if (sendFlag == 1) {
            oMaxNum.html("已经超过<em>" + Math.abs(maxNum - Math.floor(iLen)) + "</em>字");
            oMaxNum.css("color", "#f60");
        }
    };
  
    function btnconfirm()
    {
        $("input[name='dns_area']:checkbox").each(function(){
            var ck = $(this).attr("checked");
            if(ck){
                var EmpCode = $(this).attr("EmpCode");
                var EmpName = $(this).attr("EmpName");
                var value = $(this).val();
                txtzuser.value+=EmpName+",";
                hdzuser.value+=value+",";
            }
        });
        jq.ui.loadContent('nowaud', false, false, 'pop');
    }


    function Save(){
            if(typeof(fnCustomCheck)=="function")
            {
                var _msg = fnCustomCheck();
                if(_msg!="")
                {
                    alert(_msg);
                    return;
                }
            }
            setValue();
            var btnSubmit=parent.document.getElementById('btnCensorSubmit')
            if(checkInputData()=="0")
             {
                  if( typeof btnSubmit!= "undefined")
                  {
                    btnSubmit.disabled = false;
                  }
                   return;
             }

           var isSuccess=jQuery('#form1').validationEngine('validate');
           if(isSuccess==false)
           {
                 if( typeof btnSubmit!= "undefined")
                  {
                    btnSubmit.disabled = false;
                  }
                  return;
           }
            //在保存前，将数据从UI绑定到实体中
            if(typeof(_DataTable)!="undefined")
            {
               if(fnCheckEmpty()==false)
               {
                    alert("明细数据没有录入");
               }
               _DataTable.GetData();
            }

            if(typeof(fnCustomSave)=="function")
            {
                fnCustomSave();
                return ;
            }

            if(typeof(trySave)=="function")
            {
                
                if(typeof(_DataTable)!="undefined")
                {
                    $("#jsonDetails").val($.toJSON(_DataTable.Rows).replace(/'/g,"[B]").replace(/\+/g,"[J]"));
                    //$("#Details").val($.toJSON(instance[0]));
                    //instance[0].datarows = _DataTable.Rows;
                }
                var json =$.toJSON(instance[0]).replace(/'/g,"[B]").replace(/\+/g,"[J]");
                if(typeof(_DataTable)!="undefined")
                {
                    if(_DataTable.Rows.length>0){
                        json = json+"[@@@]"+$.toJSON(_DataTable.Rows);
                    }
                }
                //var json =$.toJSON(instance[0]).replace(/'/g,"[B]").replace(/\n/g,'[BR]');
                $("#jsonDataContent").val(json);
                trySave();
                return;
            }
            fnSystemSave();
        }

        ///------------------------------------
        //系统的保存方法
        ///------------------------------------
        var action = '<% =DataAction %>';
        function setValue()
        {
           <asp:Literal ID="jSave" runat="server"></asp:Literal>

           if(typeof(_DataTable)=="undefined"){
              
               $("#fieldForm").SetFormValueToObject(instance[0]);
           }
           else
           {   
               $("#Master").SetFormValueToObject(instance[0]);
           }
           //instance[0].datarows =decodeURIComponent($.toJSON(_DataTable.Rows));
           //instance[0]= $("form1").extractObject(); 
        }
        function fnSystemSave()
        {
            ///初始化相关参数
            setValue();
            $("#jsonDataContent").val($.toJSON(instance[0]));
            var SaveUrl =url+"?r=" + Math.random() + "&entity=" + entity + "&action="+action+"&json=" + encodeURI($("#jsonDataContent").val().replace(/&/g,"[A]").replace(/'/g,"[B]"));
             if(typeof(checkData)=="function")
            {
                 if(checkData()=="0")
                 {
                     return;
                 }
             }
            ///调用验证
            if(typeof(fnCheckData)=="function")
            {
                var msg =fnCheckData(instance[0]);
                if(!msg=="")
                {
                    alert(msg);
                    return;
                }
            }
            //发送保存请求
            YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
                success: responseSuccess
                ,
                failure: responseFailure
            }, null);
        }
        $(function(){

           $("textarea").bind("input",function(){
               ResizeTextarea();
            });
           $("textarea").bind("keyup",function(){
               ResizeTextarea();
            });
            $("textarea").bind("propertychange",function(){
               ResizeTextarea();
            });
        })
       
        function ResizeTextarea(){ 
        // 最小高度 
        var minHeight = 100; 
        // 最大高度，超过则出现滚动条 
        var maxHeight = 300; 
        //event.
        
        var t = event.srcElement; 
        h = t.scrollHeight; 
        h = h > minHeight ? h : minHeight; 
        h = h > maxHeight ? maxHeight : h; 
        t.style.height = h + "px"; 
        } 
       ///初始化相关信息
       $(document).ready(function() {
           //初始化流程控制器
           WFM.init(_UserName, _TableName, _WorkflowId, _WorktaskId, _WorkFlowInsId, _WorkTaskInsId, _OperatorInsId); 

           <asp:Literal ID="jInitControl" runat="server"></asp:Literal>
          
           //编辑状态
           if(getid!="")
           {
               //$("#form1").JSONToForm($.toJSON(instance[0]));
               $("#form1").JSONToForm(instance[0]);
           }
           if(typeof (userPropertyValues) != "undefined")
           {
                $("#form1").JSONToFormDefaultPropertyValues($.toJSON(userPropertyValues[0]));
           }
            
            
           $("#form1").LabelModel();
           if( typeof (TaskTitle) != "undefined")
           {
                var eTitle=document.getElementById('bpmTitle')
                if (typeof (eTitle) != "undefined"&&eTitle!=null)
                {
                   document.getElementById('bpmTitle').value=TaskTitle;
                }
           }
           //时间日期加初如事件
            var fieldForm=$("#fieldForm");
                if( typeof fieldForm!= "undefined")
                {
                var _date=$("input[type=Date]");
                initControls(_date,"Date");
                var _datetime=$("input[type=Time]");
                initControls(_datetime,"Time");
                }
           

           if( typeof (MasterFormRoles) != "undefined")
           {
             if(MasterFormRoles!=null)
             {
                 if( typeof (MasterFormRoles.ReadonlyPropertyValue) != "undefined")
                 {
                    $("#form1").ReadonlyModel(MasterFormRoles.ReadonlyPropertyValue);
                }
                if( typeof (MasterFormRoles.RequiredPropertyValue) != "undefined")
                {
                    $("#form1").RequiredModel(MasterFormRoles.RequiredPropertyValue);
                }
                if( typeof (MasterFormRoles.HidePropertyValue) != "undefined")
                {
                    $("#form1").HideModel(MasterFormRoles.HidePropertyValue);
                }
                
             }
           }

     
          if(typeof(fnInitFormCustomFunc)=="function")
          {
             fnInitFormCustomFunc();
          }
          jQuery("#form1").validationEngine();
        });
         

        // 初始时间控件
         var initControls = function(matchArray,ControlType)
         {
             if (matchArray) {
                    for (var i = 0; i < matchArray.length; i++) 
                    {
                       var cId=matchArray[i].id;
                       var controlID='#'+cId;
                       if(!IsReadonlyModel(cId))
                        {
                           $(matchArray[i]).attr('click', function(evt) {
                                var curr = new Date().getFullYear();
                                var optt = {}
                                optt.date = { preset: 'date' , minDate: new Date(2010, 3, 10, 9, 22), maxDate: new Date(2015, 7, 30, 15, 44)};
                                optt.datetime = { preset: 'datetime', minDate: new Date(2012, 3, 10, 9, 22), maxDate: new Date(2015, 7, 30, 15, 44), stepMinute: 5 };
                                optt.time = { preset: 'time' };
                                optt.select = { preset: 'select' };
                                if(ControlType== 'Date')
                                {
                                    jq(controlID).mscroller('destroy').mscroller($.extend(optt['date'], { theme: 'default', mode:'scroller', display: 'model', lang: 'english' }));
                                }
                                else if(ControlType== 'Time')
                                {
                                    jq(controlID).mscroller('destroy').mscroller($.extend(optt['time'], { theme: 'default', mode:'scroller', display: 'model', lang: 'english' }));
                                }
                            });
                        }
                    }
                }
     
         }
         $(document).ready(function() {
            jq("#txtsubject").bind("longTap",function(evt){
                jq("#txtsubject").val("同意！");
		    });
            jq("#txtsubject").bind("swipe",function(evt){
                jq("#txtsubject").val("不同意！");
		    });
         });
        function IsReadonlyModel(controlID)
        {
        
           var isReadonly=false;
           if( typeof (MasterFormRoles) != "undefined")
           {
                 if(MasterFormRoles!=null)
                 {
                    if( typeof (MasterFormRoles.ReadonlyPropertyValue) != "undefined")
                     {
                            var _obj=MasterFormRoles.ReadonlyPropertyValue;
                            $.each(_obj, function (property, value) 
                            {
                               if (value != "") 
                               { 
                                  if(value==controlID)
                                  {
                                   isReadonly=true;
                                   return false;
                                  }
                               }
                            });  
                     }
                 }
             }
             return isReadonly;
        }
   

         var formReForm;
         function doReform() {
            // load the css
            formReForm = new FormReForm('fieldForm');
            //formReForm.loadformReFormCss();
            // do the reform with default settings
            formReForm.doReForm();

        }
        var trySave = function()   
        {
            // argument formId can be the id or name attribute value of the
            // HTML form, or an HTML form object.
            setValue();
            if(typeof(fnCheckData)!="undefined")
            {
                var msg = fnCheckData();
                if(typeof(msg)!="undefined")
                {
                   alert(msg);
                   return;
                } 
            }
            var formObject = document.getElementById('form2');
            YAHOO.util.Connect.setForm(formObject);
            // This example facilitates a POST transaction.  The POST data(HTML form)
            // are initialized when calling setForm(), and it is automatically
            // included when calling asyncRequest.
            if(typeof(_DataTable)!="undefined"){
                if(_DataTable.Rows.length==0)
                {
                    var cObj = YAHOO.util.Connect.asyncRequest('POST',url+"?from=AutoLoadForm&flag=1&action="+action+"&entity="+entity,callback);
                }
                else
                {
                    var cObj = YAHOO.util.Connect.asyncRequest('POST',url+"?from=AutoLoadForm&isBatch=true&flag=1&action="+action+"&entity="+entity,callback);
                }
            }
            else
            {
               var cObj = YAHOO.util.Connect.asyncRequest('POST',url+"?from=AutoLoadForm&flag=1&action="+action+"&entity="+entity,callback);
            }
        }
     
       function Check() {
            var IsCheck = '1';
            var userloginname = hdzuser.value.split(",");
            
            for (i = 0; i < userloginname.length; i++) {
                if (_LoginName == userloginname[i]) {
                    alert("不能转发当前人");
                    IsCheck = '0';
                }
            }
           
            return IsCheck;
        }
        var responseSuccess = function (res) {
               try {
                        var str = res.responseText;
                        //var obj = eval(str);
                   
                        if(str=="1")
                        {
                                  var _workflowfell=$("input[dtype=workflowfell]");
                                  var _workflowfellName='';
                                  var _workflowfellValue='';
                                  if(_workflowfell.length>0)
                                  {
                                      _workflowfellName=$(_workflowfell[0]).val();
                                      _workflowfellValue=$(_workflowfell[0]).prev().val();
                                  }
                                  
                                   var Title=$("#bpmTitle").val();
                                   var _Tooltip = WF.NewTip();
                                   if (typeof (_OperatorInsId) != "undefined") 
                                   {
                                      
                                        var msg='';
                                        if (_IsPagereturn == '1') //1：表示启动节点
                                        {
 
                                                //不定期；
                                                if (typeof (_workflowfellValue) != "undefined") 
                                                {
                                                    if (Value != '') {WF.FreeFlow.init(_WorkflowId, _WorktaskId, _workflowfellValue, _workflowfellName);}
                                                }
                                                WFM.UpdateTitle(Title);
                                                //提交流程
                                                WFM.WFRun('提交');
                                                _Tooltip = WF.getTooltip();

                                                    msg = '标题：' + _Tooltip.title + ';执行结果：' + _Tooltip.TaskToWhoMsg;
                                                alert(msg);


                                            }//----------_IsPagereturn 
                                            else 
                                            {
                                                     var isCheck=Check();
                                                       if(isCheck=='1')
                                                       {
                                                            //提交审批意见
                                                            var transmit = hdzuser.value;//需完善：转发字符串，转发人
                                                           var strUserName=txtzuser.value;//转发人姓名字符串
                                                            var approvalMessage = $("#txtsubject").val();
                                                            if (approvalMessage == '') { alert('您输入的审批意见不能为空，请重新输入！');jq.ui.loadContent('nowaud', false, false, 'pop');jq.ui.hideMask();}
                                                            else
                                                            {
                                                                    var IsSuccess = WFM.SaveApproval(transmit,strUserName,approvalMessage);                                          
                                                                    //IsSuccess(1:成功 0：失败)
                                                                    if (IsSuccess == '1') 
                                                                    {
                                                                                    //提交流程
                                                                                WFM.WFRun('提交');
                                                                                _Tooltip = WF.getTooltip();


                                                                                    msg = '标题：' + _Tooltip.title + ';执行结果：' + _Tooltip.TaskToWhoMsg;
                                                                                custom_close(msg);

                                                                    }//-------------IsSuccess
                                   
                                                            }//---------------approvalMessage

                                                        }//------------------isCheck
                                                    }//_IsPagereturn else

                                    }//----------------_OperatorInsId

                        }//---------------------str
                        else
                        {
                            if(str!=""){
                                custom_close(str+"\n"+"数据保存失败!");
                            }
                        }
                    }
                    catch (e) {}
                    finally {}
        };
        var responseFailure =function (error) {
                    alert("数据错误：" + error.statusText);
        }
 
        function custom_close(msg){
            jq.ui.hideMask();
            jq("#jQUi").popup({ title:"提示",
	        message:msg,
	        cancelText:"不关闭", 
	        cancelCallback: function(){},
	        doneText:"关闭当前页",
	        doneCallback: function(){
                if (navigator.appName == "Netscape")
                {
                    window.open('', '_self', '');
                    window.close();
                }
                else
                {
                    if (navigator.appName == "Microsoft Internet Explorer")
                    {
                        window.opener = "whocares";
                        window.opener = null;
                        window.open('', '_top');
                        window.close();
                    }
                }
            }, 
            cancelOnly:false}
                );
        }


        // Create a callback object that defines success and failure
        // handlers, and instructs Connection Manager to use the
        // Flash transport by defining the xdr property and setting
        // it to true.
       var  callback = {
            success:responseSuccess,
            failure:responseFailure
        };
 
       var SetControlValue=function(o)
       {
            $.each(o, function (property, value) {
            //try {
            value = value + "";
            // find the control and set value
            if (property != "") {
                var control = $("[name='" + property + "']");
                var strValue = value.replace(/@1@1@1/g, "'");
                strValue = strValue.replace(/@2@2@2/g, '"');
                strValue = strValue.replace(/@@@@/g, "\n");
                strValue = strValue.replace(/[BR]/g, "\n");
                control.val(strValue);
                try {
                    $('#' + property).combobox('setValue', strValue);
                } catch (Error) { }
            }
            //  };
        });
       }

       function audaction()
             {
                 jq("#jQUi").actionsheet(
                    [{
                        text: '批准',
                        cssClasses: 'red',
                        handler: function () {
                                jq.ui.showMask("处理中....");
                                Save();
                        }
                    }, 
                    {
                        text: '退回',
                        cssClasses: 'blue',
                        handler: function () { 
                        jq.ui.showMask("处理中....");
                               //提交审批意见
                                var transmit = '';
                                var strUserName='';//转发人姓名字符串
                                var approvalMessage = $("#txtsubject").val();
                                if (approvalMessage == '') { alert('您输入的审批意见不能为空，请重新输入！');jq.ui.loadContent('nowaud', false, false, 'pop');}
                                else
                                {
                                        var IsSuccess = WFM.SaveApproval(transmit,strUserName, approvalMessage);                                          
                                        //IsSuccess(1:成功 0：失败)
                                        if (IsSuccess == '1') 
                                        {
                                                  var _Tooltip = WF.NewTip();
                                                    //提交流程
                                                     WFM.TaskBack();
                                                    _Tooltip = WF.getTooltip();
                                                    msg = '标题：' + _Tooltip.title + ';执行结果：' + _Tooltip.TaskToWhoMsg;
                                                    custom_close(msg);
                                                    

                                        }//-------------IsSuccess
                                   
                                }//---------------approvalMessage
                        }

                    }, {
                        text: '取消',
                        cssClasses: '',
                        handler: function () { }
                    }]
                );
             }
             
</script>
<script type="text/javascript" language="javascript">
    //调用初始化控件功能
    if (typeof (fnInitControl) == "function")
    {
        fnInitControl();
    }

    $(document).ready(function () {
        jq("#txtzuser").bind("click", function (evt) {
            txtzuser.value = "";
            hdzuser.value = "";
            jq.ui.loadContent('userselect', false, false, 'pop');
            $($("#testform").siblings()).remove();
        });

        //SelectForDept
        jq("#SelectForDept").attr("class", "jq-ui-forms");
        jq("#SelectForDept").css("width", "65%");

        $("#fieldForm input").removeAttr("style");
        $("#fieldForm textarea").attr("class", "jq-ui-forms");


        if (_OperType == '12') {
            $("#txtzuser").remove();
            $("#hdzuser").remove();
            $("#zuserName").remove();
        }

        (new JsLoader()).load("../Scripts/appjs/model.<% =EntityName %>.js");
    });
    
    
</script>
<script src="../Scripts/Jquery/uni-form/uni-form-validation.jquery.js" type="text/javascript"></script>
<%if (!string.IsNullOrEmpty(DetailsJson))
  { %>
<script src="../Scripts/Jquery.form.datatable.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
        _DataTable.FExpression="<% = FKExpression %>";
        _DataTable.setDataTableURL("../Extend/AjaxData/DataTableJSONList.aspx");
        _DataTable.setBusinessID(getid);
        $(document).keypress(function (e) {
            if (e.ctrlKey && e.which == 13) {
                alert("");
            }
        });
        <%=DetailsInstance %>

        if ($("#Details").length > 0) {
            //明细表权限。
           if( typeof (DetailsFormRoles) != "undefined")
           {
             if(DetailsFormRoles!=null)
             {
                if( typeof (DetailsFormRoles.ReadonlyPropertyValue) != "undefined")
                {
                    $("#form1").ReadonlyModel(DetailsFormRoles.ReadonlyPropertyValue);
                }
                if( typeof (DetailsFormRoles.RequiredPropertyValue) != "undefined")
                {
                    $("#form1").RequiredModel(DetailsFormRoles.RequiredPropertyValue);
                }
                if( typeof (DetailsFormRoles.HidePropertyValue) != "undefined")
                {
                    $("#form1").HideTableModel(DetailsFormRoles.HidePropertyValue,DetailsFormRoles.TableName);
                }
             }
           }

            _DataTable._DataBind();
            //_DataTable.AddRow();
        }
        $(document).bind('keydown', 'ctrl+1',function (evt){
            if(evt.ctrlKey && evt.which==49){
                _DataTable.AddRow();
            }
            if(evt.ctrlKey && evt.which==46){
                _DataTable.DeleteRow();
            }
        });
        setTimeout(fnSelected,300);
</script>
<%} %>

<script type="text/javascript" language="javascript">
    function LoadMingxi()
    {
        if (jq("#divdetail").get() == null || jq("#divdetail").get() == "undefind")
        {
            var htitle = new Array();
            var bconte = "";
            $("#data_head").find("td").each(function (i) { htitle.push($(this).text()) });
            if (jq("#divdetails").get() == null || jq("#divdetails").get() == "undefind")
            {
                $("#" + _TableName + "_a tbody").find("tr").each(function (i)
                {
                    bconte += "<fieldset><legend>" + parseInt(i + 1) + "</legend>"
                    $("#id" + i).find("td").each(function (j)
                    {
                        bconte += htitle[j] + "<br><input class='jq-ui-forms'  type='text' readonly='readonly' value='" + $(this).find("input").val() + "'><br>";
                        
                    });
                    bconte += "</fieldset>";
                });
                $("#" + _TableName + "_a").after("<div id='divdetails'>" + bconte + "</div>");
                if (document.getElementById(_TableName + "_a") != null)
                {
                    document.getElementById(_TableName + "_a").style.display = "none";
                }
            }
        }
        jq.ui.loadContent('Details', false, false, 'slide');
    }
</script>
</html>